module.exports = {
  config: [{
    pageId: 1,
    pageUrl: "/pages/home/home",
    isTab: true,
    isHome: true
  }, {
    pageId: 2,
    pageUrl: "/pages/project/projectlist/projectlist",
    isTab: true
  }, {
    pageId: 3,
    pageUrl: "/pages/investor/investorlist/investorlist",
    isTab: true
  }, {
    pageId: 4,
    pageUrl: "/pages/article/articlelist/articlelist",
    isTab: true
  }, {
    pageId: 5,
    pageUrl: "/pages/usercenter/usercenter",
    isTab: true
  }, {
    pageId: 6,
    pageUrl: "/pages/login/login"
  }, {
    pageId: 7,
    pageUrl: "/pages/project/projectdetail/projectdetail"
  }, {
    pageId: 8,
    pageUrl: "/pages/investor/investordetail/investordetail"
  }, {
    pageId: 9,
    pageUrl: "/pages/article/articledetail/articledetail"
  }, {
    pageId: 10,
    pageUrl: "/pages/user/baseinfo/baseinfo"
  }, {
    pageId: 11,
    pageUrl: "/pages/user/usermessage/usermessage"
  }, {
    pageId: 12,
    pageUrl: "/pages/user/userpreference/userpreference"
  }, {
    pageId: 13,
    pageUrl: "/pages/user/uservip/uservip"
  }, {
    pageId: 14,
    pageUrl: "/pages/user/usercollection/usercollection"
  }, {
    pageId: 15,
    pageUrl: "/pages/user/useragreement/useragreement"
  }, {
    pageId: 16,
    pageUrl: "/pages/user/publish/publish"
  }, {
    pageId: 17,
    pageUrl: "/pages/user/userprogress/userprogress"
  }, {
    pageId: 18,
    pageUrl: "/pages/user/supplement/supplement"
  }, {
    pageId: 19,
    pageUrl: "/pages/valuation/valuation"
  }, {
    pageId: 20,
    pageUrl: "/pages/headline/headlinelist/headlinelist"
  }, {
    pageId: 21,
    pageUrl: "/pages/headline/headlinedetail/headlinedetail"
  }],

  /**
   * 查找相应的页面
   * @pageId 页面id
   */
  find: function(pageId) {
    let result = this.config[0];
    this.config.forEach(item => {
      if (item.pageId.toString() === pageId.toString()) {
        result = item;
      }
    });
    return result;
  },

  /**
   * 创建分享参数
   * @obj 分享键值对
   * [默认内置share_id]
   */
  build: function(obj) {
    if (!(obj instanceof Object)) {
      obj = {};
    }
    let userInfo = getApp().globalData.userInfo;
    if (userInfo.share_id) {
      obj.shareId = userInfo.share_id;
    }
    let params = [];
    for (let name in obj) {
      params.push(name + "=" + obj[name]);
    }
    return params.join("&");
  },

  /**
   * 基础分享
   * @title 标题
   * @params url参数
   * @imageUrl 图片[默认截图]
   */
  baseshare: function({
    title,
    params,
    imageUrl
  }) {
    return {
      title: title,
      path: "/pages/home/home?" + this.build(params),
      imageUrl: imageUrl || ""
    }
  }

}